package com.youku.collector;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class ConsumerController {

	private Consumer consumer;

	private Executor executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);

	private int number = 1;

	public ConsumerController(Consumer consumer) {
		this.consumer = consumer;
	}

	public ConsumerController(Consumer consumer, int number) {
		super();
		this.consumer = consumer;
		this.number = number;
	}

	public void start() {
		for (int i = 0; i < number; i++) {
			executor.execute(consumer);
		}

	}
}
